/*
 * @# SessionFetcher.java 2011-5-20 上午11:14:41
 * 
 * Copyright (C) 2010 - 2011 广州羿安信息科技有限公司
 * Guangzhou ianswer information technology co. ltd.
 * 
 * All rights reserved!
 */
package com.ianswer.px.utils;


import javax.servlet.http.HttpSession;

import com.ianswer.px.user.entity.UserSession;

/**
 * 
 * @author alvin hwang
 */
public final class SessionFetcher {

	/**
	 * 登录用户
	 */
	private static final String USER = "user";

	private final HttpSession session;

	private SessionFetcher(final HttpSession session) {
		this.session = session;
	}

	public static SessionFetcher from(final HttpSession session) {
		return new SessionFetcher(session);
	}

	public UserSession getUser() {
		return (UserSession) session.getAttribute(USER);
	}

	public void setUser(UserSession userSession) {
		session.setAttribute(USER, userSession);
	}
}
